/*
 * @Author: rxn 1003312535@qq.com
 * @Date: 2023-02-17 22:22:18
 * @LastEditors: rxn 1003312535@qq.com
 * @LastEditTime: 2024-10-08 16:59:14
 * @FilePath: \vue3-progect\src\main.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { App, createApp } from "vue";
import AppVue from "./App.vue";
//公共样式
import "@/assets/css/index.less";

//公共样式变量
// import './styles/var/index.less';

//测试接口数据---moke
import "@/api/mokejs/moke.js";

//element-plus 黑暗模式样式
import "element-plus/theme-chalk/dark/css-vars.css";

let app: App<Element> = createApp(AppVue);
//pinia
import { setupStore } from "./store/setupStore.ts";
//国际化
import { setupI18n, i18n } from "./locales/setupI18n";

//路由
import { setupRouter, router } from "./router/setupRouter.ts";
//element-plus icon图标
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
//公共组件
import plugin from "@/plugin/commonComponent";
import { setupRouterGuard } from "./router/guard/setupRouterGuard";
import directiveRegister from "@/plugin/directive";

async function bootstrap() {
	//pinia
	await setupStore(app);
	// console.log(store,'store-main.js')
	//国际化
	await setupI18n(app);
	// console.log(i18n,'i18n-main.js')
	//路由
	await setupRouter(app);
	// console.log(router,'router-main.js')
	//路由守卫
	setupRouterGuard(router);

	//element-plus icon图标
	for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
		app.component(key, component);
	}

	//公共组件
	app.use(plugin);
	//共用指令
	app.use(directiveRegister);

	app.mount("#app");
}

bootstrap();
